package service.credit.impl;

import java.util.List;

import model.app.AppLoantype;
import dao.app.AppLoantypeDao;
import exception.Exceptions;
import service.credit.AppLoantypeService;

public class AppLoantypeServiceImpl implements AppLoantypeService {
	private AppLoantypeDao appLoantypeDao;

	public AppLoantypeDao getAppLoantypeDao() {
		return appLoantypeDao;
	}

	public void setAppLoantypeDao(AppLoantypeDao appLoantypeDao) {
		this.appLoantypeDao = appLoantypeDao;
	}

	@Override
	public List<AppLoantype> getLoanTypeList() {
		return this.appLoantypeDao.findModel("isdone = 1");
	}

	@Override
	public List<AppLoantype> getAllLoanTypeList() {
		return this.appLoantypeDao.findAll();
	}

	@Override
	public void save(List<AppLoantype> appLoantypeList) throws Exceptions {
		for(AppLoantype appLoantype : appLoantypeList){
			try {
				this.appLoantypeDao.save(appLoantype);
			} catch (Exception e) {
				throw new Exceptions("贷款种类保存失败，请检查你的信息是否正确！");
			}
		}
	}
	

}
